package com.ruoyi.transaction.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.transaction.domain.YZMCommonQuestions;
import com.ruoyi.transaction.service.IYZMCommonQuestionsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 常见问题：用于展示用户常见问题及解决方案Controller
 * 
 * @author yzm
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/yzmquestions")
public class YZMCommonQuestionsController extends BaseController
{
    @Autowired
    private IYZMCommonQuestionsService yZMCommonQuestionsService;

    /**
     * 查询常见问题：用于展示用户常见问题及解决方案列表
     */
    @RequiresPermissions("transaction:yzmquestions:list")
    @GetMapping("/list")
    public TableDataInfo list(YZMCommonQuestions yZMCommonQuestions)
    {
        startPage();
        List<YZMCommonQuestions> list = yZMCommonQuestionsService.selectYZMCommonQuestionsList(yZMCommonQuestions);
        return getDataTable(list);
    }

    /**
     * 导出常见问题：用于展示用户常见问题及解决方案列表
     */
    @RequiresPermissions("transaction:yzmquestions:export")
    @Log(title = "常见问题：用于展示用户常见问题及解决方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YZMCommonQuestions yZMCommonQuestions)
    {
        List<YZMCommonQuestions> list = yZMCommonQuestionsService.selectYZMCommonQuestionsList(yZMCommonQuestions);
        ExcelUtil<YZMCommonQuestions> util = new ExcelUtil<YZMCommonQuestions>(YZMCommonQuestions.class);
        util.exportExcel(response, list, "常见问题：用于展示用户常见问题及解决方案数据");
    }

    /**
     * 获取常见问题：用于展示用户常见问题及解决方案详细信息
     */
    @RequiresPermissions("transaction:yzmquestions:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(yZMCommonQuestionsService.selectYZMCommonQuestionsById(id));
    }

    /**
     * 新增常见问题：用于展示用户常见问题及解决方案
     */
    @RequiresPermissions("transaction:yzmquestions:add")
    @Log(title = "常见问题：用于展示用户常见问题及解决方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YZMCommonQuestions yZMCommonQuestions)
    {
        return toAjax(yZMCommonQuestionsService.insertYZMCommonQuestions(yZMCommonQuestions));
    }

    /**
     * 修改常见问题：用于展示用户常见问题及解决方案
     */
    @RequiresPermissions("transaction:yzmquestions:edit")
    @Log(title = "常见问题：用于展示用户常见问题及解决方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YZMCommonQuestions yZMCommonQuestions)
    {
        return toAjax(yZMCommonQuestionsService.updateYZMCommonQuestions(yZMCommonQuestions));
    }

    /**
     * 删除常见问题：用于展示用户常见问题及解决方案
     */
    @RequiresPermissions("transaction:yzmquestions:remove")
    @Log(title = "常见问题：用于展示用户常见问题及解决方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(yZMCommonQuestionsService.deleteYZMCommonQuestionsByIds(ids));
    }
}
